#include "tools.h"
#include "Source.h"

void lens_padding(float* lens_ray_to_xy_out, float* ray_in)
{
    float cx = ray_in[0];
    float cy = ray_in[1];
    float fx = ray_in[2];
    float fy = ray_in[3];

    float atan_value = 0;
    float value = 0;
    float among = 0;
    float among_1 = 0;

    for (uint32_t i = 0; i < 76800; i++)
    {
        if (i % 320 == 0)
        {
            among = (i / 320 - cy) / fy;
            value = among * among;
        }
        among_1 = (i % 320 - cx) / fx;
        atan_value = sqrt(among_1 * among_1 + value);
        lens_ray_to_xy_out[i] = 1 / (sqrt(1 + atan_value * atan_value));
    }
}

// int U_test(void)
// {
//     float* ptr = malloc(76800 * sizeof(float));
//     lens_padding(ptr,ray_25);
//     write_csv(file_path,ptr);
//     free(ptr);
//     return 1;
// }